<?php
class AdminAction extends Action{
	function login(){
		if($_POST['hid'] == 1){
			$vv = md5($_POST['vv']);
			if($vv === $_SESSION['verify']){
				$user = D('admin');
				$name = addslashes($_POST['name']);
				$pwd = md5($_POST['pwd']);
				$lab = $user->field('name')->where("name='$name' and pwd='$pwd'")->find();
				if(!empty($lab)){
					$_SESSION['name'] = $lab['name'];
					go('/Admin','登录成功!');
				}
			}
		}
		
		$this->display('admin@login');
	}
	
	function logout(){
		$_SESSION['name'] = '';
		go('/Admin/login','退出成功！');
	}
	
	function index(){
		$this->check();
		$user = D('admin');
		$list = $user->findAll();
		$this->assign('list',$list);
		$this->display('admin@index');
	}
	
	function top(){
		$this->check();
		$this->display('admin@top');	
	}
	
	function menu(){
		$this->check();
		$this->display('admin@menu');
	}
	
	function main(){
		$this->check();
		$this->display('admin@main');	
	}
	
	function check(){
		if($_SESSION['name']==''){
			go('/Admin/login','',1);
		}
	}
	
	function vv(){
		import('ORG.Util.Image');
		Image::buildImageVerify();
	}
	
	
}
?>